package com.android.lyricshow.adapter;

import java.util.ArrayList;

import com.android.lyricshow.R;
import com.android.lyricshow.bean.ArtistBean;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ArtistAdapter extends BaseAdapter {
	
	private Context mContext	= null;
	private ArrayList<ArtistBean> mArtistList = null;
	
	public ArtistAdapter(Context context, ArrayList<ArtistBean> list){
		mContext	= context;
		mArtistList	= list;
	}
	
	@Override
	public int getCount() {
		return mArtistList.size();
	}

	@Override
	public Object getItem(int position) {
		return mArtistList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return mArtistList.get(position).getID();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder vh = null;
		
		if(convertView == null){
			convertView = LayoutInflater.from(mContext).inflate(R.layout.artist_list_item, null);
			
			vh = new ViewHolder();
			vh.tv = (TextView)convertView.findViewById(R.id.artist_title);
			
			convertView.setTag(vh);
		}else{
			vh = (ViewHolder)convertView.getTag();
		}
		
		vh.tv.setText(mArtistList.get(position).getName());
		return convertView;
	}
	
	static class ViewHolder{
		TextView tv;
	}

}
